package com.micro.school.system.controller.discount;

import java.util.List;

import com.micro.school.common.core.utils.poi.ExcelUtil;
import com.micro.school.common.core.web.controller.BaseController;
import com.micro.school.common.core.web.domain.AjaxResult;
import com.micro.school.common.core.web.page.TableDataInfo;
import com.micro.school.common.log.annotation.Log;
import com.micro.school.common.log.enums.BusinessType;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.micro.school.system.domain.vo.DiscountStudentVo;
import com.ruoyi.system.service.IDiscountStudentService;


/**
 * 【优惠学生管理】Controller
 * 
 * @author rakic
 * @date 2025-08-05
 */
@RestController
@RequestMapping("/student")
public class DiscountStudentController extends BaseController
{
    @Autowired
    private IDiscountStudentService discountStudentService;

    /**
     * 查询【优惠学生管理】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DiscountStudentVo discountStudentVo)
    {
        startPage();
        List<DiscountStudentVo> list = discountStudentService.selectDiscountStudentList(discountStudentVo);
        return getDataTable(list);
    }

    /**
     * 导出【优惠学生管理】列表
     */
    @Log(title = "【优惠学生管理】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DiscountStudentVo discountStudentVo)
    {
        List<DiscountStudentVo> list = discountStudentService.selectDiscountStudentList(discountStudentVo);
        ExcelUtil<DiscountStudentVo> util = new ExcelUtil<DiscountStudentVo>(DiscountStudentVo.class);
        util.exportExcel(response, list, "【优惠学生管理】数据");
    }

    /**
     * 获取【优惠学生管理】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(discountStudentService.selectDiscountStudentById(id));
    }

    /**
     * 新增【优惠学生管理】
     */
    @Log(title = "【优惠学生管理】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DiscountStudentVo discountStudentVo)
    {
        return toAjax(discountStudentService.insertDiscountStudent(discountStudentVo));
    }

    /**
     * 修改【优惠学生管理】
     */
    @Log(title = "【优惠学生管理】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DiscountStudentVo discountStudentVo)
    {
        return toAjax(discountStudentService.updateDiscountStudent(discountStudentVo));
    }

    /**
     * 删除【优惠学生管理】
     */
    @Log(title = "【优惠学生管理】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(discountStudentService.deleteDiscountStudentByIds(ids));
    }


}
